package com.ktjy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktjy.pages.ProjectPage;
import com.ktjy.pojo.Storage;
import com.ktjy.service.StorageService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 查询库存信息
 */
@Controller
public class StorageController {
    @Autowired
    StorageService storageService;
    @RequestMapping("/storage/list")
    public Object storageList(String prodName, String stkWarehouse,@RequestParam(defaultValue = "1") Integer pageIndex ,@RequestParam(defaultValue = "3") Integer pageSize, Model model){
        IPage<Storage> storageIPage = new Page<>(pageIndex,pageSize);
        Page<Storage> page = (Page<Storage>) storageService.pageList(storageIPage,prodName,stkWarehouse);
        ProjectPage<Storage> projectPage = new ProjectPage<>();
        BeanUtils.copyProperties(page,projectPage);
        model.addAttribute("storagePage",projectPage);
        return "/storage/list";
    }
}
